# -*- coding;utf-8 -*-
"""
File name : MyEncoder.PY
Program IDE : PyCharm
Create file time: 2023/6/7 14:15
File Create By Author : 朱清闯
"""
import json
import datetime


class MyEncoder(json.JSONEncoder):
    def default(self, obj):
        if isinstance(obj, datetime.datetime):
            print("MyEncoder-datetime.datetime")
            return obj.strftime("%Y-%m-%d %H:%M:%S")
        if isinstance(obj, bytes):
            return str(obj, encoding='utf-8')
        if isinstance(obj, int):
            return int(obj)
        elif isinstance(obj, float):
            return float(obj)
        elif isinstance(obj, bytes):
            return str(obj, encoding="utf-8")
        else:
            return super(MyEncoder, self).default(obj)
